<extend name="Base/common"/>

<block name="style">
    <link href="__CSS__/help.css" rel="stylesheet" type="text/css"/>

</block>

<block name="body">
<script type="text/javascript" src="__PUBLIC__/Core/js/multi_upload.js"></script>
<script type="text/javascript" src="__STATIC__/uploadify/jquery.uploadify.min.js"></script>

<div class="col-md-12">
    <include file="Public/user_info"/>
    <include file="Public/_top_menu"/>
</div>

<div class="col-md-12 ">
    <div class="bgwhite pull-left" style="width:100%;min-height: 400px;padding-bottom: 50px;margin-top: 0">
        <div class="help_h" style="">
            <a href="{:U('help/index/detail',array('id'=>$help_id))}" class="pull-left "
               style="width: 120px;">帮忙描述</a>
            <a href="{:U('help/index/evaluate',array('id'=>$help_id))}" class="pull-left active"
               style="width: 120px;">帮忙评价</a>
            <a href="{:U('help/index/production',array('id'=>$help_id))}" class="pull-left "
               style="width: 120px;">帮忙作品</a>
        </div>


        <div class="evaluate_list" style="padding: 0px 50px 10px 100px;">
            <if condition="!$evaluate">
                <div class="row">
                    <div class="col-xs-12">
                        <p class="text-muted" style="text-align: center; font-size: 3em;">
                            <br/>
                            暂时没有任何评价～
                            <br/>
                        </p>
                    </div>
                </div>
            </if>
            <volist name="evaluate" id="eva">
                <div class="" style="padding:10px 0; ">
                    <div class="pull-right" style="color: #a0a0a0"> 评价于{$eva.create_time|friendlyDate}</div>
                    <div class="clearfix">
                        <div class="pull-left text-center" style="width: 64px;">
                            <a class="author " href="{$eva.user.space_url}"> <img src="{$eva.user.avatar64}"></a>
                            <a class="author clearfix  " href="{$eva.user.space_url}">{$eva.user.nickname} </a>
                        </div>

                            <span class="glyphicon glyphicon-arrow-right pull-left"
                                  style="font-size: 25px;color: #a0a0a0;height: 64px;line-height: 64px;padding: 0 10px;"></span>

                        <div class="pull-left text-center" style="width: 64px;">
                            <a class="author " href="{$eva.to_user.space_url}"> <img src="{$eva.to_user.avatar64}"></a>
                            <a class="author clearfix  "
                               href="{$eva.to_user.space_url}">{$eva.to_user.nickname} </a>
                        </div>


                        <div class="pull-left" style="margin-left: 20px">
                            <a class="author" href="{$eva.user.space_url}">{$eva.user.nickname} </a> 对 <a
                                class="author" href="{$eva.to_user.space_url}">{$eva.to_user.nickname} </a>评价：<span
                                style="color: #a0a0a0">
            {$eva.type|get_evaluate_type}
            &nbsp;&nbsp;&nbsp;&nbsp;守时（{$eva.punctual}分）&nbsp;&nbsp;&nbsp;&nbsp;守信（{$eva.trustworthy}分）&nbsp;&nbsp;&nbsp;&nbsp;技能（{$eva.technique}分）&nbsp;&nbsp;&nbsp;&nbsp;态度（{$eva.attitude}分）
            </span>

                            <div class="evaluate_content" style="padding: 20px 0 20px 0;color: #a0a0a0;max-width: 660px;">
                                {$eva.content}
                            </div>
                            <php>if(!empty($eva['attaches'][0])){</php>
                            <div class="images popup-gallery" style="width: 100%">
                                <volist name="eva['attaches']" id="attach">
                                    <a class="popup" href="{$attach|get_cover='path'}" title="点击查看大图"><img
                                            src="{:getThumbImageById($attach,100,100)}" width="100" height="100"
                                            style="margin-right: 7px;margin-bottom: 7px;"></a>
                                </volist>
                            </div>
                            <php>}</php>
                            <div>

                            </div>
                        </div>
                    </div>
                </div>
                <div class="dashed"></div>
            </volist>
        </div>

        <div class="clearfix text-center">
            {:getPagination($totalCount,$r)}
        </div>

        <php>if(check_is_accept($help_id) && !check_is_evaluate($help_id)){</php>

        <div style="padding: 50px;">
            <h2>
                我还没评论
            </h2>
            {:W('Evaluate/evaluate',array('help_id'=>$help_id))}
        </div>
        <php>}</php>


        <php>if(check_is_my_publish($help_id)){
        if(!empty($attend)){
        </php>

        <div style="padding: 50px;">
            <h2>
                以下用户我还没评价
            </h2>

            <form class="form-horizontal ajax-form" role="form" action="{:U('help/index/doEvaluate')}"
                  method="post"
                  id="edit-article-form">
                <php>
                    $fileSizeLimit = floor(8 * 1024) . 'KB';
                </php>
                <volist name="attend" id="vo">
                    <div class="solid clearfix" style="margin: 20px 0;"></div>
                    <div class="col-md-2 col-xs-12 text-center">
                        <a class="author " href="{$vo.user.space_url}"> <img src="{$vo.user.avatar128}"></a>
                        <a class="author clearfix  " href="{$vo.user.space_url}">{$vo.user.nickname} </a>
                    </div>
                    <div class="col-md-10 col-xs-12">

                        <div class="row list_{$vo['uid']}">
                            <div class="col-xs-12">
                                <input type="hidden" name="user{$vo['uid']}[help_id]" value="{$help_id}"/>
                                <input type="hidden" name="user{$vo['uid']}[to_uid]" value="{$vo['uid']}"/>

                                    <div class="col-sm-12 has-feedback" style="">
                                        <div class="form-group ">
                                            <div class="col-sm-12 pull-left">
                                                <div class="pull-left" style="width: 100%">
                                                    <label>好评&nbsp;<input type="radio" value="1"
                                                                          name="user{$vo['uid']}[type]" checked></label>&nbsp;&nbsp;
                                                    <label>中评&nbsp;<input type="radio" value="2"
                                                                          name="user{$vo['uid']}[type]"></label>&nbsp;&nbsp;
                                                    <label>差评&nbsp;<input type="radio" value="3"
                                                                          name="user{$vo['uid']}[type]"></label>

                                                    <div style="width: 100%">
                                                        <div class="pull-left">
                                                            {:W('Score/score_arr',array('title'=>'punctual','content'=>'守时','row_id'=>$vo['uid']))}
                                                            {:W('Score/score_arr',array('title'=>'trustworthy','content'=>'守信','row_id'=>$vo['uid']))}
                                                            {:W('Score/score_arr',array('title'=>'technique','content'=>'技能','row_id'=>$vo['uid']))}
                                                            {:W('Score/score_arr',array('title'=>'attitude','content'=>'态度','row_id'=>$vo['uid']))}
                                                        </div>

                                                    </div>

                                                </div>
                                                <div class="dashed pull-left"
                                                     style="width: 100%;margin-bottom: 20px;"></div>
                                                <textarea name="user{$vo['uid']}[content]" class="form-control"
                                                          style="height: 100px;"></textarea>
                                            </div>
                                            <div class="col-sm-12">
                                                <div>添加现场照</div>
                                                <div class="pull-left publish_work_image_list" id="add_image">
                                                    <input type="hidden" name="user{$vo['uid']}[image]"
                                                           id="image_{$vo['uid']}">

                                                    <div class="img-list clearfix">
                                                        <ul id="ul_{$vo['uid']}" style="-webkit-padding-start: 0px;">
                                                            <li id="btn_{$vo['uid']}"><input style="display:none"
                                                                                             id="uploadify_{$vo['uid']}"
                                                                                             type="file"/></li>
                                                        </ul>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                    </div>

                            </div>
                        </div>
                    </div>
                    <p class="" style="margin: 0 auto 20px auto;width: 200px;">
                        <button data-id="{$vo['uid']}" type="submit" class="btn btn-large btn-primary button_change"
                                id="submit-button">
                            <span id="submit-content">
                                    发表评价
                            </span>
                        </button>
                    </p>
                    <script>
                        $(function () {
                            bindImageUpload("{$vo['uid']}");
                        })

                    </script>
                </volist>
                <div class="solid clearfix" style="margin: 20px 0;"></div>
                <p class="" style="margin: 0 auto 20px auto;width: 200px;">
                    <button data-id="all" type="submit" class="btn btn-large btn-primary button_change"
                            id="submit-button">
                            <span id="submit-content">
                                    全部提交
                            </span>
                    </button>
                </p>
            </form>
        </div>

        <php>}}</php>


    </div>
</div>

<script>

    $(function () {
        $('.popup-gallery').each(function () { // the containers for all your galleries
            $(this).magnificPopup({
                delegate: '.popup',
                type: 'image',
                tLoading: 'Loading image #%curr%...',
                mainClass: 'mfp-img-mobile',
                gallery: {
                    enabled: true,
                    navigateByImgClick: true,
                    preload: [0, 1] // Will preload 0 - before current, and 1 after the current image
                },
                image: {
                    tError: '<a href="%url%">The image #%curr%</a> could not be loaded.',
                    titleSrc: function (item) {
                        /*           return item.el.attr('title') + '<small>by Marsel Van Oosten</small>';*/
                        return '';
                    }
                }
            });
        });
    });
</script>


<script>
    function bindImageUpload(unid) {
        fileSizeLimit = "{$fileSizeLimit}"
        $('#uploadify_' + unid).uploadify({
            formData: {
                attach_type: 'feed_image',
                upload_type: 'image',
                thumb: 1,
                width: 100,
                height: 100,
                cut: 1,
                PHPSESSID: "<?php echo session_id(); ?>"
            },
            fileSizeLimit: fileSizeLimit,
            fileTypeDesc: 'Image Files',
            fileTypeExts: '*.jpg; *.png; *.gif;',
            swf: '__STATIC__/uploadify/uploadify.swf',
            uploader: "{:U('Home/File/uploadPicture',array('session_id'=>session_id()))}",
            width: 80,
            height: 80,
            buttonImage: '__ROOT__/Addons/InsertImage/_static/image/add-photo-multi.png',
            queueSizeLimit: 0,
            queueID: true,
            overrideEvents: ['onSelectError', 'onDialogClose'],
            onUploadSuccess: function (file, data, response) {
                var jsondata = $.parseJSON(data);
                multi_upload.removeLoading(unid);
                if (jsondata.status === 1) {
                    $('#btn_' + unid).before($('<li id="li_' + unid + '_' + file.index + '"><img src="' + jsondata.path + '" width="80" height="80" /><a href="javascript:;" onclick="multi_upload.removeImage(\'' + unid + '\', ' + file.index + ', ' + jsondata.id + ')"><span class="del">删除</span></a></li>').fadeIn('slow'));
                }
                multi_upload.upAttachVal('add', jsondata.id, unid);
            },
            onUploadStart: function (file) {
                multi_upload.addLoading(unid);
            },
            onSelectError: function (file, errorCode, errorMsg) {
                switch (errorCode) {
                    case -100:
                        toast.error('选择的上传数目超过，您还能上传' + errorMsg + '个图片');
                        break;
                    case -110:
                        toast.error("文件 [" + file.name + "] 大小超出系统限制的" + $('#uploadify_' + unid).uploadify('settings', 'fileSizeLimit') + "大小", 4);
                        break;
                    case -120:
                        toast.error("文件 [" + file.name + "] 大小异常");
                        break;
                    case -130:
                        toast.error("文件 [" + file.name + "] 类型不正确");
                        break;
                }
            },
            onFallback: function () {
                toast.error('您未安装FLASH控件，无法上传！请安装FLASH控件后再试');
            }
        });
    }

</script>
<php>if(check_is_my_publish($help_id)){</php>
<script>
    $(document).on('click', 'button[type=submit]', function (e) {
        //取消默认动作，防止表单两次提交
        e.preventDefault();

        //禁用提交按钮，防止重复提交
        var btn = $(this);
        var form = $('form.ajax-form');
        // $('[type=submit]', form).addClass('disabled');

        //获取提交地址，方式
        var action = form.attr('action');
        var method = form.attr('method');

        //检测提交地址
        if (!action) {
            return false;
        }

        //默认提交方式为get
        if (!method) {
            method = 'get';
        }
        if (btn.attr('data-id') == 'all') {
            //获取表单内容
            var formContent = form.serialize();
        }
        else {
            //获取表单内容
            var formContent = $('.list_' + btn.attr('data-id') + ' [name]').serialize();
        }

        //发送提交请求
        var callable;
        if (method == 'post') {
            callable = $.post;
        } else {
            callable = $.get;
        }
        callable(action, formContent, function (a) {
            handleAjax(a);
            $('[type=submit]', form).removeClass('disabled');
        });

        //返回
        return false;
    });
</script>

<php>}</php>

</block>












